package cn.iocoder.yudao.module.promotion.dal.mysql.shortlinklog;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.promotion.controller.admin.shortlinklog.vo.ShortLinkLogExportReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.shortlinklog.vo.ShortLinkLogPageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.shortlinklog.ShortLinkLogDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 短链接访问记录 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ShortLinkLogMapper extends BaseMapperX<ShortLinkLogDO> {

    default PageResult<ShortLinkLogDO> selectPage(ShortLinkLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShortLinkLogDO>()
                .likeIfPresent(ShortLinkLogDO::getGenerateeName, reqVO.getGenerateeName())
                .eqIfPresent(ShortLinkLogDO::getShortLinkId, reqVO.getShortLinkId())
                .likeIfPresent(ShortLinkLogDO::getShortLinkName, reqVO.getShortLinkName())
                .eqIfPresent(ShortLinkLogDO::getBatchNumber, reqVO.getBatchNumber())
                .eqIfPresent(ShortLinkLogDO::getShortUrl, reqVO.getShortUrl())
                .eqIfPresent(ShortLinkLogDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(ShortLinkLogDO::getIp, reqVO.getIp())
                .eqIfPresent(ShortLinkLogDO::getEquipment, reqVO.getEquipment())
                .eqIfPresent(ShortLinkLogDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ShortLinkLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShortLinkLogDO::getId));
    }

    default List<ShortLinkLogDO> selectList(ShortLinkLogExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShortLinkLogDO>()
                .likeIfPresent(ShortLinkLogDO::getGenerateeName, reqVO.getGenerateeName())
                .eqIfPresent(ShortLinkLogDO::getShortLinkId, reqVO.getShortLinkId())
                .likeIfPresent(ShortLinkLogDO::getShortLinkName, reqVO.getShortLinkName())
                .eqIfPresent(ShortLinkLogDO::getBatchNumber, reqVO.getBatchNumber())
                .eqIfPresent(ShortLinkLogDO::getShortUrl, reqVO.getShortUrl())
                .eqIfPresent(ShortLinkLogDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(ShortLinkLogDO::getIp, reqVO.getIp())
                .eqIfPresent(ShortLinkLogDO::getEquipment, reqVO.getEquipment())
                .eqIfPresent(ShortLinkLogDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ShortLinkLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShortLinkLogDO::getId));
    }

}
